package com.woniu.payservice;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.woniu.payservice.config.Constants;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

@SpringBootApplication
@EnableCaching//开启缓存
@EnableScheduling//开启定时任务
@EnableEurekaClient//开启注册中心客户端
@EnableFeignClients//开启声明式通信
@MapperScan(value = "com.woniu.payservice.dao")
public class PayserviceApplication {

    public static void main(String[] args) {
        SpringApplication.run(PayserviceApplication.class, args);
    }

//    @Bean
//	public AlipayClient createAliPayClient(){
//		//读取配置文件
//		File f = new File("AliPay.properties");
//		FileReader r = null;
//		Properties env = new Properties();
//		DefaultAlipayClient defaultAlipayClient = null;
//		try {
//			r = new FileReader(f);
//			try {
//				env.load(r);
//				System.out.println("11111111111111111111111111111111");
//				String gatewayUrl = env.getProperty(Constants.PROP_OPEN_GATEWAY_URL);
//				String app_id = env.getProperty(Constants.PROP_OPEN_APP_ID);
//				String format = env.getProperty(Constants.PROP_OPEN_FORMAT);
//				String charset = env.getProperty(Constants.PROP_OPEN_CHARSET);
//				String merchant_private_key = env.getProperty(Constants.PROP_OPEN_APP_PRIVATE_KEY);
//				String alipay_public_key = env.getProperty(Constants.PROP_OPEN_ALIPAY_PUBLIC_KEY);
//				String sign_type = env.getProperty(Constants.PROP_OPEN_SIGN_TYPE);
//			} catch (IOException e) {
//				e.printStackTrace();
//			}
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		} finally {
//			if (r != null) {
//				try {
//					r.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//		}
//		return  defaultAlipayClient;
//	}
}
